package com.wy.controller;

import com.wy.Service.PostionService;
import com.wy.pojo.Postion;
import com.wy.pojo.Role;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/postion")
@CrossOrigin
public class PostionController {

    @Resource
    private PostionService postionService;
    String msg;

    @GetMapping("/list")
    public  List<Postion> findAll(){
        return postionService.findAll();
    }

    @GetMapping("/add")
    public String add(Postion postion){
        try{
            postionService.add(postion);
            msg="添加成功";
        }catch (Exception e){
            msg="添加失败";
        }
        return msg;
    }

    @GetMapping("/delete")
    public String delete(Integer id){
        try{
            postionService.delete(id);
            msg="删除成功";
        }catch (Exception e){
            msg="删除失败";
        }
        return msg;
    }
    @GetMapping("/update")
    public String update(Postion postion){
        try{
            postionService.update(postion);
            msg="修改成功";
        }catch (Exception e){
            msg="修改失败";
        }
        return msg;
    }


}
